/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */
class Solution {
public:
bool CommpareNode(TreeNode* node2 , TreeNode* node1)
{
	if (node1 == NULL && node2 == NULL) 
	{
		return true;
	}
	else if(node1 != NULL && node2 != NULL)
	{
		return node1->val == node2->val;
	}else{
		return false;
	}


}

bool isSymmetric(TreeNode* root)
{
	if (root == NULL)
		return true;
	
	bool isbotton = true;
	vector<TreeNode*> vec1 , vec2;
	vec1.push_back(root->left);
	vec1.push_back(root->right);
	while (true)
	{
		for (size_t i = 0; i < vec1.size()/2; i++)
		{	
			if (vec1[i] != NULL || vec1[vec1.size()-1 - i] != NULL)
				isbotton = false;

			if (CommpareNode(vec1[i] , vec1[vec1.size()-1-i]) == false){
				return false;
			}
			
		}

		vec2.clear();
		for (size_t i = 0; i < vec1.size(); i++)
		{
			if (vec1.at(i) != NULL)
			{
				vec2.push_back(vec1.at(i)->left);
				vec2.push_back(vec1.at(i)->right);
			}				
		}

		if (isbotton == true)
			break;
		vec1 = vec2;
		isbotton = true;
	}

	return true;
}
};